//
//  LKDiscountTicketViewController.m
//  YLHelper
//
//  Created by she1323 on 2018/5/4.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKDiscountTicketViewController.h"
#import "LKDiscountTicketNoViewController.h"
#import "LKDiscountTicketYesViewController.h"
#import "SegmentTapView.h"
#import "FlipTableView.h"
#import "LKChooseFileTypeViewController.h"
#import "LKUploadFileViewController.h"
@interface LKDiscountTicketViewController ()<SegmentTapViewDelegate,FlipTableViewDelegate>
@property (nonatomic, strong)SegmentTapView *segment;
@property (nonatomic, strong)FlipTableView *flipView;
@end

@implementation LKDiscountTicketViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setSegmentControlView];
    // Do any additional setup after loading the view.
}
-(void)setNavgationBackBtn{
    [super setNavgationBackBtn];
    self.navigationItem.title = @"可用优惠券";
}
-(void)setSegmentControlView{
    WS(weakSelf)
    LKBaseLineView *topLine = [LKBaseLineView setLineView];
    topLine.frame = CGRectMake(0, NAVIGATION_BAR_HEIGHT, WIDTH, 1);
    [self.view addSubview:topLine];
    self.segment = [[SegmentTapView alloc] initWithFrame:CGRectMake(8,NAVIGATION_BAR_HEIGHT + 9, WIDTH - 16, 27) withDataArray:[NSArray arrayWithObjects:@"可叠加优惠券",@"不可叠加优惠券", nil] withFont:14];
    self.segment.delegate = self;
    self.segment.lineColor = [UIColor clearColor];
    self.segment.titleFont = 14;
    self.segment.textNomalColor = COLOR_HEX(0x4A78E8);
    self.segment.textSelectedColor = [UIColor whiteColor];
    self.segment.layer.borderColor = COLOR_HEX(0x4A78E8).CGColor;
    self.segment.layer.borderWidth = 1;
    self.segment.layer.cornerRadius = 8;
    self.segment.layer.masksToBounds = YES;
    [self.view addSubview:self.segment];
    
    LKDiscountTicketYesViewController *list1 = [[LKDiscountTicketYesViewController alloc] init];
    list1.isOrderUpdate = self.isOrderUpdate;
    [list1.popSubject subscribeNext:^(id  _Nullable x) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    list1.addOrderModel = self.addOrderModel;
    [list1.pushSubject subscribeNext:^(id  _Nullable x) {
//        LKChooseFileTypeViewController *vc = [[LKChooseFileTypeViewController alloc] init];
        LKUploadFileViewController *vc = [[LKUploadFileViewController alloc] init];
        vc.addOrderModel = weakSelf.addOrderModel;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    LKDiscountTicketNoViewController *list2 = [[LKDiscountTicketNoViewController alloc] init];
    list2.isOrderUpdate = self.isOrderUpdate;
    [list2.popSubject subscribeNext:^(id  _Nullable x) {
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
    list2.addOrderModel = self.addOrderModel;
    [list2.pushSubject subscribeNext:^(id  _Nullable x) {
//        LKChooseFileTypeViewController *vc = [[LKChooseFileTypeViewController alloc] init];
        LKUploadFileViewController *vc = [[LKUploadFileViewController alloc] init];
        vc.addOrderModel = weakSelf.addOrderModel;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    LKBaseLineView *bottomLine = [LKBaseLineView setLineView];
    bottomLine.frame = CGRectMake(0, NAVIGATION_BAR_HEIGHT + 44, WIDTH, 1);
    [self.view addSubview:bottomLine];
    self.flipView = [[FlipTableView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT + 45, WIDTH, HEIGHT - (NAVIGATION_BAR_HEIGHT + 45)) withArray:@[list1,list2]];
    self.flipView.delegate = self;
    [self.view addSubview:self.flipView];
}
#pragma mark -------- select Index
-(void)selectedIndex:(NSInteger)index
{
    NSLog(@"%ld",index);
    [self.flipView selectIndex:index];

}

-(void)scrollChangeToIndex:(NSInteger)index
{
    NSLog(@"%ld",index);
    [self.segment selectIndex:index];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
